package com.juhe.weather;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;

import com.juhe.weather.bean.FutureWeatherBean;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.junit.Test;
import org.junit.runner.RunWith;

import java.util.ArrayList;
import java.util.List;

import static org.junit.Assert.*;

/**
 * Instrumentation test, which will execute on an Android device.
 *
 * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
 */
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
    @Test
    public void useAppContext() throws Exception {
        // Context of the app under test.
        Context appContext = InstrumentationRegistry.getTargetContext();

        assertEquals("com.juhe.weather", appContext.getPackageName());

        String str1="\"future\":{\"day_20170306\":{\"temperature\":\"-3℃~9℃\",\"weather\":\"多云转晴\",\"weather_id\":{\"fa\":\"01\",\"fb\":\"00\"},\"wind\":\"北风4-5 级\",\"week\":\"星期一\",\"date\":\"20170306\"},\"day_20170307\":{\"temperature\":\"-1℃~8℃\",\"weather\":\"晴\",\"weather_id\":{\"fa\":\"00\",\"fb\":\"00\"},\"wind\":\"北风3-4 级\",\"week\":\"星期二\",\"date\":\"20170307\"},\"day_20170308\":{\"temperature\":\"0℃~12℃\",\"weather\":\"晴\",\"weather_id\":{\"fa\":\"00\",\"fb\":\"00\"},\"wind\":\"北风3-4 级\",\"week\":\"星期三\",\"date\":\"20170308\"},\"day_20170309\":{\"temperature\":\"2℃~15℃\",\"weather\":\"晴\",\"weather_id\":{\"fa\":\"00\",\"fb\":\"00\"},\"wind\":\"南风微风\",\"week\":\"星期四\",\"date\":\"20170309\"},\"day_20170310\":{\"temperature\":\"4℃~16℃\",\"weather\":\"多云转阴\",\"weather_id\":{\"fa\":\"01\",\"fb\":\"02\"},\"wind\":\"南风微风\",\"week\":\"星期五\",\"date\":\"20170310\"},\"day_20170311\":{\"temperature\":\"-1℃~8℃\",\"weather\":\"晴\",\"weather_id\":{\"fa\":\"00\",\"fb\":\"00\"},\"wind\":\"北风3-4 级\",\"week\":\"星期六\",\"date\":\"20170311\"},\"day_20170312\":{\"temperature\":\"2℃~15℃\",\"weather\":\"晴\",\"weather_id\":{\"fa\":\"00\",\"fb\":\"00\"},\"wind\":\"南风微风\",\"week\":\"星期日\",\"date\":\"20170312\"}}}";
        org.json.JSONObject  json= null;
        try {
            json = new org.json.JSONObject(str1);
            JSONArray futurnArray = json.getJSONArray("future");
            List<FutureWeatherBean> futureList = new ArrayList<FutureWeatherBean>();
            for(int i=0;i<futurnArray.length();i++){
                JSONObject futureJson = futurnArray.getJSONObject(i);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }

    }
}
